/*
 * @Author: lmk
 * @Date: 2022-05-26 12:28:24
 * @LastEditTime: 2022-06-04 22:12:50
 * @LastEditors: lmk
 * @Description: 
 */
import React from 'react'
import { Navigate, useRoutes } from 'react-router-dom'
import { NotFund,HomePage, Shareholding} from '@/pages'
import Loading from '@/components/pageLoading'
// import { withCache } from './withCache'
type CutonFallBackT =
  | boolean
  | React.ReactChild
  | React.ReactFragment
  | React.ReactPortal
  | null
type ChildT = React.LazyExoticComponent<() => JSX.Element> | React.FC
export interface routeItem {
  path: string
  element: JSX.Element
  exact?: boolean
  name?: string
  icon?: string
  unCompleted?: boolean | undefined
}
// 加载异步组件的loading
const SuspenseWrapper = (Child: ChildT, cutonFallBack?: CutonFallBackT) => {
  return (
    <React.Suspense fallback={cutonFallBack || <Loading />}>
      <Child />
    </React.Suspense>
  )
}
// 首页产品列表
// const IndexCacheList = withCache(Index)
export const menuList:routeItem[] = [{
  path: '/shareholding',
  element:SuspenseWrapper(Shareholding),
  exact: true,
  name:'主力持股跟踪',
  icon: 'icon-14shuju'
},{
  path: '/shareholding',
  element:<Shareholding />,
  exact: true,
  name:'万维诊股',
  icon: 'icon-22guwen',
  unCompleted: true
},{
  path: '/shareholding',
  element:<Shareholding />,
  exact: true,
  name:'主力追踪',
  icon: 'icon-15shangzhang',
  unCompleted: true
},{
  path: '/shareholding',
  element:<Shareholding />,
  exact: true,
  name:'情绪打板',
  icon: 'icon-4xijin',
  unCompleted: true
},{
  path: '/shareholding',
  element:<Shareholding />,
  exact: true,
  name:'主力分析',
  icon: 'icon-12fenxi',
  unCompleted: true
},{
  path: '/shareholding',
  element:<Shareholding />,
  exact: true,
  name:'高抛低吸',
  icon: 'icon-24shengzhi',
  unCompleted: true
},{
  path: '/shareholding',
  element:<Shareholding />,
  exact: true,
  name:'量化组合',
  icon: 'icon-5niushi',
  unCompleted: true
}]
const Routes = () => {
  const RouterList =  useRoutes([
    ...menuList,
    {
      path: '/',
      element: SuspenseWrapper(HomePage),
    },
    {
      path: '/404',
      element: SuspenseWrapper(NotFund)
    },
    { path: '*', element: <Navigate to="/404" replace /> }
  ])
  return RouterList
}
export default Routes